<template>
  <div>
    <div class="searchLayout">
    <a-input-search
      placeholder="input search text"
      enter-button="Search"
      size="large"
      v-model="keyWord"
      @search="toSearch()"
    />
  </div>
    <a-table :columns="columns" :data-source="lastList">
      
    </a-table>
  </div>
</template>
<script>
// import UserSearch from "../../components/admin/UserSearch";

const columns = [
  {
    title: "username",
    dataIndex: "username",
    key: "username",
  },
  {
    title: "nickname",
    dataIndex: "nickname",
    key: "nickname",
  },
  {
    title: "description",
    dataIndex: "description",
    key: "description",
  },
  // {
  //   title: "操作",
  //   dataIndex: "description",
  //   key: "description",
  // },
];

// const userList = [
//   // {
//   //   key: "1",
//   //   name: "John Brown",
//   //   age: 32,
//   //   address: "New York No. 1 Lake Park",
//   //   tags: ["nice", "developer"],
//   // },
//   // {
//   //   key: "2",
//   //   name: "Jim Green",
//   //   age: 42,
//   //   address: "London No. 1 Lake Park",
//   //   tags: ["loser"],
//   // },
//   // {
//   //   key: "3",
//   //   name: "Joe Black",
//   //   age: 32,
//   //   address: "Sidney No. 1 Lake Park",
//   //   tags: ["cool", "teacher"],
//   // },
// ];

export default {
  components:{
    // UserSearch,
  },
  data() {
    return {
      userList:[],
      searchUserList:[],
      lastList:[],
      columns,
      keyWord:'',
    };
  },
  created(){
    this.$api.admin.getUserList('').then((res) => {
        // console.log(res);
        if(res.code==1){
            this.userList = res.data.list;
            this.lastList = this.userList;

                        console.log(res);
            // this.userInfo.username = res.data.username;          

        }
        // this.data = res.data.data;
        // this.loading = false;
      });
  },
  methods:{
    toSearch(){
      if(this.keyWord && this.keyWord.length>0){
        let param = {
        keyWord: this.keyWord,

        };


        this.$api.admin.searchUser(param).then((res) => {
        // console.log(res);
        if(res.code==1){
            this.searchUserList = res.data.list;
                        console.log(res);
            // this.userInfo.username = res.data.username;          
            this.lastList = this.searchUserList;
        }
        // this.data = res.data.data;
        // this.loading = false;
      });

      }else{
        this.lastList = this.userList;
      }
    },
  }
};
</script>

<style lang="scss" scoped>
.searchLayout {
    margin: 16px;
}
</style>